package web.servlet;

import domain.Account;
import domain.Cart;
import domain.Category;
import service.CatalogService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

public class MyAccountFormServlet extends HttpServlet {

    private static final String MY_ACCOUNT_FORM = "/WEB-INF/jsp/account/myAccountForm.jsp";
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
        Account loginAccount = (Account) session.getAttribute("loginAccount");
        List<Category> categories = new CatalogService().getCategoryList();
        session.setAttribute("account",loginAccount);
        session.setAttribute("categories",categories);

        req.getRequestDispatcher(MY_ACCOUNT_FORM).forward(req,resp);
    }
}
